/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.ipti.br.tag.bean.lazy;

import org.ipti.br.tag.dao.UnityFacade;
import org.ipti.br.tag.entity.Unity;
import java.util.List;
import java.util.Map;
import org.primefaces.model.LazyDataModel;
import org.primefaces.model.SortOrder;

/**
 *
 * @author israel
 */
public class LazyUnityDataModel extends LazyDataModel<Unity>{
    private UnityFacade unityDAO;
    private List<Long> unities;

    public LazyUnityDataModel(UnityFacade unityDAO, List<Long> unities) {
        this.unityDAO = unityDAO;
        this.unities = unities;
    }   
    
    @Override
    public List<Unity> load(int first, int pageSize, String sortField, SortOrder sortOrder, Map<String, String> filters) {
        return unityDAO.activatedUnitiesPerID(unities, first, pageSize, filters);
    }

    @Override
    public int getRowCount() {
        return unityDAO.getUnityCount(unities);
    }

    public List<Long> getUnities() {
        return unities;
    }

    public void setUnities(List<Long> unities) {
        this.unities = unities;
    }

    public UnityFacade getUnityDAO() {
        return unityDAO;
    }

    public void setUnityDAO(UnityFacade unityDAO) {
        this.unityDAO = unityDAO;
    }    
    
}
